<!DOCTYPE html><html><head><title>README</title><link href="http://www.jboss.org/jdf/stylesheets/documentation.css" rel="stylesheet"></link><link href="http://www.jboss.org/jdf/stylesheets/pygments.css" rel="stylesheet"></link></head><body>
<h1><a id="kitchensinkear-example-using-multiple-java-ee-6-technologies-deployed-as-an-ear" class="anchor" href="#kitchensinkear-example-using-multiple-java-ee-6-technologies-deployed-as-an-ear"><span class="anchor-icon"></span></a>kitchensink-ear: Example Using Multiple Java EE 6 Technologies Deployed as an EAR</h1>

<p>Author: Pete Muir<br/>
Level: Intermediate<br/>
Technologies: EAR<br/>
Summary: Based on kitchensink, but deployed as an EAR<br/>
Target Product: EAP<br/>
Product Versions: EAP 6.1, EAP 6.2<br/>
Source: <a href="https://github.com/jboss-developer/jboss-eap-quickstarts/">https://github.com/jboss-developer/jboss-eap-quickstarts/</a>  </p>

<h2><a id="what-is-it" class="anchor" href="#what-is-it"><span class="anchor-icon"></span></a>What is it?</h2>

<p>This is your project! It is a sample, deployable Maven 3 project to help you get your foot in the door developing with Java EE 6 on Red Hat JBoss Enterprise Application Platform. </p>

<p>This project is setup to allow you to create a compliant Java EE 6 application using JSF 2.0, CDI 1.0, EJB 3.1, JPA 2.0 and Bean Validation 1.0. It includes a persistence unit and some sample persistence and transaction code to introduce you to database access in enterprise Java. </p>

<p><em>Note: This quickstart uses the H2 database included with JBoss EAP 6. It is a lightweight, relational example datasource that is used for examples only. It is not robust or scalable and should NOT be used in a production environment!</em></p>

<h2><a id="system-requirements" class="anchor" href="#system-requirements"><span class="anchor-icon"></span></a>System requirements</h2>

<p>The application this project produces is designed to be run on Red Hat JBoss Enterprise Application Platform 6.1 or later. </p>

<p>All you need to build this project is Java 6.0 (Java SDK 1.6) or later, Maven 3.0 or later.</p>

<h2><a id="configure-maven" class="anchor" href="#configure-maven"><span class="anchor-icon"></span></a>Configure Maven</h2>

<p>If you have not yet done so, you must <a href="../README.html#configure-maven">Configure Maven</a> before testing the quickstarts.</p>

<h2><a id="start-the-jboss-server" class="anchor" href="#start-the-jboss-server"><span class="anchor-icon"></span></a>Start the JBoss Server</h2>

<ol>
<li>Open a command line and navigate to the root of the JBoss server directory.</li>
<li><p>The following shows the command line to start the server:</p>
<div class="highlight"><pre><span class="n">For</span> <span class="n">Linux</span><span class="o">:</span>   <span class="n">JBOSS_HOME</span><span class="o">/</span><span class="n">bin</span><span class="o">/</span><span class="n">standalone</span><span class="p">.</span><span class="n">sh</span>
<span class="n">For</span> <span class="n">Windows</span><span class="o">:</span> <span class="n">JBOSS_HOME</span><span class="err">\</span><span class="n">bin</span><span class="err">\</span><span class="n">standalone</span><span class="p">.</span><span class="n">bat</span>
</pre></div></li>
</ol>

<h2><a id="build-and-deploy-the-quickstart" class="anchor" href="#build-and-deploy-the-quickstart"><span class="anchor-icon"></span></a>Build and Deploy the Quickstart</h2>

<p><em>NOTE: The following build command assumes you have configured your Maven user settings. If you have not, you must include Maven setting arguments on the command line. See <a href="../README.html#build-and-deploy-the-quickstarts">Build and Deploy the Quickstarts</a> for complete instructions and additional options.</em></p>

<ol>
<li>Make sure you have started the JBoss Server as described above.</li>
<li>Open a command line and navigate to the root directory of this quickstart.</li>
<li><p>Type this command to build and deploy the archive:</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">clean</span> <span class="n">install</span> <span class="n">jboss</span><span class="o">-</span><span class="n">as</span><span class="o">:</span><span class="n">deploy</span>
</pre></div></li>
<li><p>This will deploy <code>target/jboss-kitchensink-ear.ear</code> to the running instance of the server.</p></li>
</ol>

<h2><a id="access-the-application-" class="anchor" href="#access-the-application-"><span class="anchor-icon"></span></a>Access the application </h2>

<p>The application will be running at the following URL: <a href="http://localhost:8080/jboss-kitchensink-ear-web">http://localhost:8080/jboss-kitchensink-ear-web</a>.</p>

<ol>
<li>Enter a name, email address, and Phone nubmer in the input field and click the <em>Register</em> button.</li>
<li>If the data entered is valid, the new member will be registered and added to the <em>Members</em> display list.</li>
<li>If the data is not valid, you must fix the validation errors and try again.</li>
<li><p>When the registration is successful, you will see a log message in the server console:</p>
<div class="highlight"><pre><span class="n">Registering</span> <span class="n">_the_name_you_entered_</span>
</pre></div></li>
</ol>

<h2><a id="undeploy-the-archive" class="anchor" href="#undeploy-the-archive"><span class="anchor-icon"></span></a>Undeploy the Archive</h2>

<ol>
<li>Make sure you have started the JBoss Server as described above.</li>
<li>Open a command line and navigate to the root directory of this quickstart.</li>
<li><p>When you are finished testing, type this command to undeploy the archive:</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">jboss</span><span class="o">-</span><span class="n">as</span><span class="o">:</span><span class="n">undeploy</span>
</pre></div></li>
</ol>

<h2><a id="run-the-arquillian-tests-" class="anchor" href="#run-the-arquillian-tests-"><span class="anchor-icon"></span></a>Run the Arquillian Tests </h2>

<p>This quickstart provides Arquillian tests. By default, these tests are configured to be skipped as Arquillian tests require the use of a container. </p>

<p><em>NOTE: The following commands assume you have configured your Maven user settings. If you have not, you must include Maven setting arguments on the command line. See <a href="../README.html#run-the-arquillian-tests">Run the Arquillian Tests</a> for complete instructions and additional options.</em></p>

<ol>
<li>Make sure you have started the JBoss Server as described above.</li>
<li>Open a command line and navigate to the root directory of this quickstart.</li>
<li><p>Type the following command to run the test goal with the following profile activated:</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">clean</span> <span class="n">test</span> <span class="o">-</span><span class="n">Parq</span><span class="o">-</span><span class="n">jbossas</span><span class="o">-</span><span class="n">remote</span> 
</pre></div></li>
</ol>

<h2><a id="investigate-the-console-output" class="anchor" href="#investigate-the-console-output"><span class="anchor-icon"></span></a>Investigate the Console Output</h2>

<p>You should see the following console output when you run the tests:</p>
<div class="highlight"><pre><span class="n">Results</span> <span class="o">:</span>
<span class="n">Tests</span> <span class="n">run</span><span class="o">:</span> <span class="mi">1</span><span class="o">,</span> <span class="n">Failures</span><span class="o">:</span> <span class="mi">0</span><span class="o">,</span> <span class="n">Errors</span><span class="o">:</span> <span class="mi">0</span><span class="o">,</span> <span class="n">Skipped</span><span class="o">:</span> <span class="mi">0</span>
</pre></div>
<h2><a id="investigate-the-server-console-output" class="anchor" href="#investigate-the-server-console-output"><span class="anchor-icon"></span></a>Investigate the Server Console Output</h2>

<p>You should see messages similar to the following:</p>
<div class="highlight"><pre><span class="n">INFO</span>  <span class="p">[</span><span class="n">org</span><span class="p">.</span><span class="n">jboss</span><span class="p">.</span><span class="n">as</span><span class="p">.</span><span class="n">server</span><span class="p">]</span> <span class="p">(</span><span class="n">management</span><span class="o">-</span><span class="n">handler</span><span class="o">-</span><span class="kr">thread</span> <span class="o">-</span> <span class="mi">9</span><span class="p">)</span> <span class="n">JBAS018559</span><span class="o">:</span> <span class="n">Deployed</span> <span class="s">&quot;test.war&quot;</span>
<span class="n">INFO</span>  <span class="p">[</span><span class="n">org</span><span class="p">.</span><span class="n">jboss</span><span class="p">.</span><span class="n">as</span><span class="p">.</span><span class="n">quickstarts</span><span class="p">.</span><span class="n">kitchensink_ear</span><span class="p">.</span><span class="n">controller</span><span class="p">.</span><span class="n">MemberRegistration</span><span class="p">]</span> <span class="p">(</span><span class="n">http</span><span class="o">--</span><span class="mf">127.0.0.1</span><span class="o">-</span><span class="mi">8080</span><span class="o">-</span><span class="mi">2</span><span class="p">)</span> <span class="n">Registering</span> <span class="n">Jane</span> <span class="n">Doe</span>
<span class="n">INFO</span>  <span class="p">[</span><span class="n">org</span><span class="p">.</span><span class="n">jboss</span><span class="p">.</span><span class="n">as</span><span class="p">.</span><span class="n">quickstarts</span><span class="p">.</span><span class="n">kitchensink_ear</span><span class="p">.</span><span class="n">test</span><span class="p">.</span><span class="n">MemberRegistrationTest</span><span class="p">]</span> <span class="p">(</span><span class="n">http</span><span class="o">--</span><span class="mf">127.0.0.1</span><span class="o">-</span><span class="mi">8080</span><span class="o">-</span><span class="mi">2</span><span class="p">)</span> <span class="n">Jane</span> <span class="n">Doe</span> <span class="n">was</span> <span class="n">persisted</span> <span class="n">with</span> <span class="n">id</span> <span class="mi">1</span>
<span class="n">INFO</span>  <span class="p">[</span><span class="n">org</span><span class="p">.</span><span class="n">jboss</span><span class="p">.</span><span class="n">weld</span><span class="p">.</span><span class="n">deployer</span><span class="p">]</span> <span class="p">(</span><span class="n">MSC</span> <span class="n">service</span> <span class="kr">thread</span> <span class="mi">1</span><span class="o">-</span><span class="mi">6</span><span class="p">)</span> <span class="n">JBAS016009</span><span class="o">:</span> <span class="n">Stopping</span> <span class="n">weld</span> <span class="n">service</span> <span class="k">for</span> <span class="n">deployment</span> <span class="n">test</span><span class="p">.</span><span class="n">war</span>
<span class="n">INFO</span>  <span class="p">[</span><span class="n">org</span><span class="p">.</span><span class="n">jboss</span><span class="p">.</span><span class="n">as</span><span class="p">.</span><span class="n">jpa</span><span class="p">]</span> <span class="p">(</span><span class="n">MSC</span> <span class="n">service</span> <span class="kr">thread</span> <span class="mi">1</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="n">JBAS011403</span><span class="o">:</span> <span class="n">Stopping</span> <span class="n">Persistence</span> <span class="n">Unit</span> <span class="n">Service</span> <span class="err">&#39;</span><span class="n">test</span><span class="p">.</span><span class="n">war</span><span class="err">#</span><span class="n">primary</span><span class="err">&#39;</span>
<span class="n">INFO</span>  <span class="p">[</span><span class="n">org</span><span class="p">.</span><span class="n">hibernate</span><span class="p">.</span><span class="n">tool</span><span class="p">.</span><span class="n">hbm2ddl</span><span class="p">.</span><span class="n">SchemaExport</span><span class="p">]</span> <span class="p">(</span><span class="n">MSC</span> <span class="n">service</span> <span class="kr">thread</span> <span class="mi">1</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="n">HHH000227</span><span class="o">:</span> <span class="n">Running</span> <span class="n">hbm2ddl</span> <span class="n">schema</span> <span class="n">export</span>
<span class="n">INFO</span>  <span class="p">[</span><span class="n">org</span><span class="p">.</span><span class="n">hibernate</span><span class="p">.</span><span class="n">tool</span><span class="p">.</span><span class="n">hbm2ddl</span><span class="p">.</span><span class="n">SchemaExport</span><span class="p">]</span> <span class="p">(</span><span class="n">MSC</span> <span class="n">service</span> <span class="kr">thread</span> <span class="mi">1</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="n">HHH000230</span><span class="o">:</span> <span class="n">Schema</span> <span class="n">export</span> <span class="n">complete</span>
<span class="n">INFO</span>  <span class="p">[</span><span class="n">org</span><span class="p">.</span><span class="n">jboss</span><span class="p">.</span><span class="n">as</span><span class="p">.</span><span class="n">connector</span><span class="p">.</span><span class="n">subsystems</span><span class="p">.</span><span class="n">datasources</span><span class="p">]</span> <span class="p">(</span><span class="n">MSC</span> <span class="n">service</span> <span class="kr">thread</span> <span class="mi">1</span><span class="o">-</span><span class="mi">5</span><span class="p">)</span> <span class="n">JBAS010409</span><span class="o">:</span> <span class="n">Unbound</span> <span class="n">data</span> <span class="n">source</span> <span class="p">[</span><span class="n">jboss</span><span class="o">/</span><span class="n">datasources</span><span class="o">/</span><span class="n">KitchensinkEarQuickstartTestDS</span><span class="p">]</span>
<span class="n">INFO</span>  <span class="p">[</span><span class="n">org</span><span class="p">.</span><span class="n">jboss</span><span class="p">.</span><span class="n">as</span><span class="p">.</span><span class="n">server</span><span class="p">.</span><span class="n">deployment</span><span class="p">]</span> <span class="p">(</span><span class="n">MSC</span> <span class="n">service</span> <span class="kr">thread</span> <span class="mi">1</span><span class="o">-</span><span class="mi">6</span><span class="p">)</span> <span class="n">JBAS015877</span><span class="o">:</span> <span class="n">Stopped</span> <span class="n">deployment</span> <span class="n">test</span><span class="p">.</span><span class="n">war</span> <span class="n">in</span> <span class="mi">19</span><span class="n">ms</span>
<span class="n">INFO</span>  <span class="p">[</span><span class="n">org</span><span class="p">.</span><span class="n">jboss</span><span class="p">.</span><span class="n">as</span><span class="p">.</span><span class="n">server</span><span class="p">]</span> <span class="p">(</span><span class="n">management</span><span class="o">-</span><span class="n">handler</span><span class="o">-</span><span class="kr">thread</span> <span class="o">-</span> <span class="mi">10</span><span class="p">)</span> <span class="n">JBAS018558</span><span class="o">:</span> <span class="n">Undeployed</span> <span class="s">&quot;test.war&quot;</span>
</pre></div>
<h2><a id="run-the-quickstart-in-jboss-developer-studio-or-eclipse" class="anchor" href="#run-the-quickstart-in-jboss-developer-studio-or-eclipse"><span class="anchor-icon"></span></a>Run the Quickstart in JBoss Developer Studio or Eclipse</h2>

<p>You can also start the server and deploy the quickstarts from Eclipse using JBoss tools. For more information, see <a href="../README.html#use-jboss-developer-studio-or-eclipse-to-run-the-quickstarts">Use JBoss Developer Studio or Eclipse to Run the Quickstarts</a> </p>

<h2><a id="debug-the-application" class="anchor" href="#debug-the-application"><span class="anchor-icon"></span></a>Debug the Application</h2>

<p>If you want to debug the source code or look at the Javadocs of any library in the project, run either of the following commands to pull them into your local repository. The IDE should then detect them.</p>
<div class="highlight"><pre>    <span class="n">mvn</span> <span class="n">dependency</span><span class="o">:</span><span class="n">sources</span>
    <span class="n">mvn</span> <span class="n">dependency</span><span class="o">:</span><span class="n">resolve</span> <span class="o">-</span><span class="n">Dclassifier</span><span class="o">=</span><span class="n">javadoc</span>
</pre></div></body></html>
